/*
 * hand.h
 *
 *  Created on: 30.11.2012
 *      Author: root
 */

#ifndef HAND_H_
#define HAND_H_
#define HEIGHT 225
#define WIDTH 225

#include "stdafx.h"
#include <vector>
typedef unsigned char uchar;

using namespace std;

class HandFinder
{
        int pos_x;
        int pos_y;
        int pos_a;

        vector <float> finger_up_x,finger_down_x;
        vector <float> finger_up_y,finger_down_y;
        vector <float> finger_up_a,finger_down_a;

        float radius_max;
        float radius_min;
        float radius_finger_mid;
        float radius_finger_low;

        uchar data[WIDTH][HEIGHT][3];
        int w;
        int h;
        float prec;
        float prec_a;
        uchar Y;
        uchar Cb;
        uchar Cr;
        int color_precision;

        bool ifOutOfArea(int x,int rc,int y,int rs);
        bool ifInArea(int x,int rc,int y,int rs);
        uchar getItem(int x,int y,int z);
        int check(int x,int max_x);
        void findIn(int x,int y);
        void findCenterGeometric(int x,int y);
        void findOut(int x,int y);
        float radius_scale(int r,int a);
public:
        HandFinder(uchar _data[WIDTH][HEIGHT][3],int _w,int _h,float _prec,float _prec_a,uchar _Y,uchar _Cb,uchar _Cr,int _color_precision);
        ~HandFinder(void);

        void setColor(uchar _Y,uchar _Cb,uchar _Cr);
        bool detectHandFromPoint(int x,int y);
        int analyseRadiusMinMax();
        bool detectFingers();
        int detectMove();

        void getPos(int &_x, int &_y);
};

#endif /* HAND_H_ */